<?php
class retrieve_themes extends retrieve_base{

	private $module_display_options 	= array();
	
	/**
	* function produces abstract structure of modules db structure
	*
    * used to generate the table structure required abstract function that passes an abstract
	* representation of the desired table structure to the proper database module which will
	* interpet the abstract and convert it into a valid SQL Create table structure.
	*
	* @return Array list of abstract table definitions for this module
	*/
	function create_table(){
		$tables = array();
		/**
		* Table structure for table 'theme client has'
		*
		* this table should only ever hold one record per client on the server 
		*/
		
		$fields = array(
			array("client_identifier"					,"unsigned integer"	,"NOT NULL"	,"default '0'"),
			array("theme_identifier"					,"unsigned integer"	,"NOT NULL"	,"default '0'")
		);
		
		$primary ="";
		$tables[count($tables)] = array("theme_client_has", $fields, $primary);
		
		//$this->db->query("INSERT INTO theme_client_has (theme_identifier,client_identifier) VALUES (1,1);");

		/**
		* Table structure for the 'theme' table
		*/
		$fields = array(
		/**
		* Basic connectivity fields
		* the page it belongs to 
		* the client that owns this data
		* the language that the document is written in default 'english' if not supplied
		*/
		array("theme_identifier"			,"unsigned integer"	,"NOT NULL"	,"auto_increment","key"),
		array("theme_label"					,"varchar(50)"		,"NOT NULL"	,"default '0'"),
		array("theme_description"			,"text"				,"NULL"		,"default ''"),
		array("theme_directory"				,"varchar(50)"		,"NOT NULL"	,"default '0'"),
		array("theme_secure"				,"unsigned integer"	,"NOT NULL"	,"default '0'")
		);
		
		$primary ="theme_identifier";
		
		
		$tables[count($tables)] = array("theme_data", $fields, $primary);
		/**
		* insert default themes 
		*/
		
		
		/**
		* Table structure for table 'theme_templates'
		* 
		* this will define the template stylesheet to load for a theme x template type
		*/
		$fields = array(
		array("template_identifier"		,"unsigned integer"	,"NOT NULL"	,"auto_increment"),
		array("template_theme"			,"unsigned integer"	,"NOT NULL"	,"default '0'"),
		array("template_xsl_file"		,"varchar(255)"		,"NOT NULL"	,"default '0'"),
		array("template_type"			,"unsigned integer"	,"NOT NULL"	,"default '0'"),
		array("template_xsl_entry"		,"varchar(255)"		,"NOT NULL"	,"default '0'")
		);
		
		$primary ="template_identifier";
		$tables[count($tables)] = array("theme_templates", $fields, $primary);
		

		/**
		* Table structure for table 'theme_types'
		*/
		$fields = array(
			array("theme_type_identifier"		,"unsigned integer"	,"NOT NULL"	,"auto_increment"),
			array("theme_type_label"			,"varchar(255)"		,"NOT NULL"	,"default ''"),
			array("theme_type_product"			,"varchar(255)"		,"NOT NULL"	,"default ''"),
			array("theme_type_command"			,"varchar(255)"		,"NOT NULL"	,"default ''"),
			array("theme_type_branch"			,"varchar(255)"		,"NOT NULL"	,"default ''"),
			array("theme_type_leaf"				,"varchar(255)"		,"NOT NULL"	,"default ''"),
			array("theme_type_field_list"		,"varchar(255)"		,"NOT NULL"	,"default 'all'")
		);
		$primary ="theme_type_identifier";
		
		$tables[count($tables)] = array("theme_types", $fields, $primary,"THEME_GENERATE_DEFAULT_DB_RECORDS");
		
		/**
		* insert basic theme types 
		*/
		/*
		
*/
		return $tables;
	}	

	/**
	* call the initialisation function only when this module is created
	*/
	function create_client_details($parameters){
	}
		

}
?>